﻿
IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_File_GetFile_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_File_GetFile_V2];
GO

CREATE PROCEDURE [dbo].[sproc_File_GetFile_V2]
    @ownerId    int,
    @fileId     int
AS
BEGIN
SET NOCOUNT ON;

SELECT
        d.[Name] as DirectoryName,
        f.FileId,
        f.DirectoryId,
        f.[Name],
        f.[Version],
        f.[Size],
        f.VPath,
        f.TimeCreated,
        f.LastModified
    FROM dbo.UDS_File_File f INNER JOIN dbo.UDS_File_Directory d ON f.DirectoryId = d.DirectoryID
    WHERE f.FileId = @fileId AND d.OwnerId = @ownerId;

RETURN 0;
END
GO

